﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BusinessLayer;

namespace WebApplication
{
    public class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        [System.Web.Services.WebMethod]
        public static List<Dictionary<string, object>> ReadAll()
        {
            List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
            Dictionary<string, object> car;

            Reader<Car> reader = Car.Repository.ReadAll();
            while (reader.Read())
            {
                car = new Dictionary<string, object>();
                car["name"] = reader.Current.Name;
                car["x"] = reader.Current.CurrentState().Location.X;
                car["y"] = reader.Current.CurrentState().Location.Y;

                result.Add(car);
            }
            reader.Close();

            return result;
        }
    }
}